/*
 * This file (AkGlower.java) is protected by the GNU GPL licence (v2). 
 * Please read the license.txt attached for further informations. 
 * 
 */

package alkwarel.brushes;

import alkwarel.objects.AkArtspace;
import alkwarel.objects.AkStampBrush;
import artx.utils.AxRandom;

/**
 * @author Xavier Gouchet
 *
 */
public class AkGlower extends AkStampBrush {

	/**
	 * Standard constructor
	 */
	public AkGlower() {
		super(3, "Glower");
	}

	/**
	 * @see alkwarel.objects.AkStampBrush#DrawStamp(alkwarel.objects.AkArtspace, float, float)
	 */
	public void DrawStamp(AkArtspace a, float posx, float posy) {
		a.noStroke();
		int col = a.g.fillColor;
		
		// random sparkling
		a.fill(255);
		float radius = AxRandom.RandF(30);
		double angle = AxRandom.RandD(2*Math.PI);
		float strength = AxRandom.RandF(radius*0.25f);
		a.ellipse((float) ((Math.cos(angle)*radius)+posx), (float) ((Math.sin(angle)*radius)+posy), strength, strength);
		
		// random smoke
		int red = (col >> 16) & 0xff;
		int gre = (col >> 8) & 0xff;
		int blu = col & 0xff;
		a.fill(red, gre, blu, 8);
		radius = AxRandom.RandF(50);
		angle = AxRandom.RandD(2*Math.PI);
		strength = AxRandom.RandF(75);
		a.ellipse((float) ((Math.cos(angle)*radius)+posx), (float) ((Math.sin(angle)*radius)+posy), strength, strength);
		
		// sparkling center
		/*
		a.ellipse(posx, posy, 13, 13);
		a.ellipse(posx, posy, 8, 8);
		a.ellipse(posx, posy, 4, 4);
		a.fill(255);
		a.ellipse(posx, posy, 3, 3);
		// */
		
		// reset color
		a.fill(col);
	}

}
